home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
digsby
/
digsbybuddy.pyo
(
.txt
)
< prev
next >
Wrap
Python Compiled Bytecode
|
2008-10-13
|
5KB
|
144 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
from jabber import jbuddy, jabber_util
from util import Timer, callsback
from common import pref, profile
from common.actions import action
from objects import ip, pagetime
jbuddy_caps = jbuddy.caps
import logging
log = logging.getLogger('digsby.buddy')
def no_widgets(self, *a, **k):
return not (self.iswidget)
class DigsbyBuddy(jbuddy):
def __init__(self, jabber_, jid, rosteritem = None):
jbuddy.__init__(self, jabber_, jid, rosteritem)
iswidget = iswidget
import digsby.widgets.widget
self.iswidget = iswidget(self)
self.ip = None
self.online_time = None
profile.account_manager.buddywatcher.unregister(self)
def is_video_widget(self):
node = self.jid.node
if node:
pass
return node.startswith('video.')
is_video_widget = property(is_video_widget)
def remove(self, callback = None):
if self.iswidget:
return callback.success()
return jbuddy.remove(self, callback = callback)
remove = action(no_widgets)(callsback(remove))
def caps(self):
cs = []
caps = caps
import common
if self.id in self.protocol.bots:
cs.append(caps.BOT)
if self.iswidget:
cs.extend([
caps.INFO,
caps.IM])
else:
cs.extend(jbuddy.get_caps(self))
return cs
caps = property(caps)
def service(self):
return 'digsby'
service = property(service)
def serviceicon(self):
skin = skin
import gui
return None if not self.iswidget else skin.get('serviceicons.widget')
serviceicon = property(serviceicon)
def update_presence(self, presence, buddy = None):
groups = jabber_util.xpath_eval(presence.xmlnode, 'd:group', {
'd': 'digsby:setgroup' })
if groups:
self.widget_to_group(groups[0].getContent())
ips = jabber_util.xpath_eval(presence.xmlnode, 'i:ip', {
'i': ip.IP_NS })
if ips:
try:
self.ip = ip.Ip(ips[0]).ip
pagetimes = jabber_util.xpath_eval(presence.xmlnode, 'p:pagetime', {
'p': pagetime.PAGETIME_NS })
if pagetimes:
try:
self.online_time = pagetime.PageTime(pagetimes[0]).pagetime / 1000
jbuddy.update_presence(self, presence, buddy = buddy)
def widget_to_group(self, groupname, callback = None):
log.info('%s add_to_group %s', self, groupname)
pending = self.pending_adds
if groupname in pending:
log.info('ignoring request.')
else:
pending.add(groupname)
item = self.protocol.roster.get_item_by_jid(self.id).clone()
if groupname not in item.groups:
item.groups[:] = [
groupname]
query = item.make_roster_push()
def onsuccess(_s):
pending.discard(groupname)
callback.success()
def onerror(_s = (None, None, (None, None, None), None)):
pending.discard(groupname)
log.warning('error adding %r to %s', self.id, groupname)
callback.error()
self.protocol.send_cb(query, success = onsuccess, error = onerror, timeout = onerror)
widget_to_group = action(needs = ((unicode, 'Group name'),))(callsback(widget_to_group))
icon_disabled = property((lambda : True), (lambda : pass))
def __repr__(self):
try:
res = len(self.resources)
except:
res = 0
try:
n = self.name
except:
n = ''
return '<DigsbyBuddy %s %d>' % (n, res)